<?php

namespace App\Http\Controllers\System;

use App\Common\Utils\JsonResponse;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class TeacherController extends Controller
{
    /** @var \App\Services\System\LogService $logService */
    private $logService;
    /** @var \App\Services\System\TeacherService $teacherService */
    private $teacherService;

    /**
    * Create a new controller instance.
    *
    * @return void
    */
    public function __construct()
    {
        parent::__construct();
        $this->middleware('auth');
        $this->logService = app('logService');
        $this->teacherService = app('teacherService');
    }

    /**
     * @Description: 获取教师列表信息数据
     * @Author: kzj
     * @datetime: 2022-11-23
     */
    public function getList(Request $request)
    {
        try
        {
            $result = $this->teacherService->getList($request->all());
            return JsonResponse::get($result['data'], TRUE, $result['total'], $result['per_page']);
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }

    /**
     * @Description: 获取教师信息数据
     * @Author: kzj
     * @datetime: 2023-03-09
     */
    public function getBaseInfo(Request $request)
    {
        try
        {
            $result = $this->teacherService->getBaseInfo($request->all());
            return JsonResponse::success($result,'操作成功');
        }
        catch(\Exception $e)
        {
            Log::error($e);
            return $this->error($e);
        }
    }

    public function getPosition(Request $request)
    {
        try
        {
            $result = $this->teacherService->getPosition($request->all());
            return JsonResponse::success($result,'操作成功');
        }
        catch(\Exception $e)
        {
            Log::error($e);
            return $this->error($e);
        }
    }

    /**
     * @Description: 更新教师考核情况
     * @Author: kzj
     * @datetime: 2023-08-31
     */
    public function updateUserAssessment(Request $request)
    {
        try
        {
            $result = $this->teacherService->updateUserAssessment($request->all());
            return JsonResponse::success($result,'操作成功');
        }
        catch(\Exception $e)
        {
            Log::error($e);
            return $this->error($e);
        }
    }

    /**
     * @Description: 批量更新教师考核情况
     * @Author: kzj
     * @datetime: 2023-08-31
     */
    public function updateUsersAssessment(Request $request)
    {
        try
        {
            $result = $this->teacherService->updateUsersAssessment($request->all());
            return JsonResponse::success($result,'操作成功');
        }
        catch(\Exception $e)
        {
            Log::error($e);
            return $this->error($e);
        }
    }

    /**
     * @Description: 导出教师信息列表数据
     * @Author: kzj
     * @datetime: 2022-11-23
     */
    public function export(Request $request)
    {
        try
        {
            $result = $this->teacherService->export($request->all());
            return JsonResponse::success($result,'操作成功');
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }

}
